<template>
	<div class="all">
		<div class="flexcc" style="padding-top: 1.3rem;"><van-icon name="success" color="#5BB20E" size="3rem" /></div>
		<div style="font-size: 0.26rem; color: #707070; text-align: center; margin-top: 0.3rem;">换卡订单提交成功</div>
		<div style="font-size: 0.3rem; color: #646464; text-align: center; margin-top: 0.3rem;">您可进入7号激活口首页上方查询物流单号</div>
		<div style="font-size: 0.3rem; color: #4F4138; text-align: center; margin-top: 0.3rem;">【流量卡可正常使用到<span style="color: #FF0000; font-weight: bold;">本月15日</span>左右】</div>
		<div style="font-size: 0.26rem; color: #646464; text-align: center; margin-top: 3.3rem; padding: 0 0.3rem;">开卡信息需要提交运营商审核，48小时左右发货， 如果审核失败，我们将会短信通知您</div>
		
		<div @click="go('/')" style="background:#FFC234; color: #FFFFFF; text-align: center; margin: 0.3rem auto; padding: 0.2rem; cursor: pointer; border-radius: 0.1rem;">返回首页</div>
	</div>
</template>

<script>
	import axios from 'axios'
	import bus from '@/assets/bus.js'
	export default {
		name: 'genghuan',
		data() {
			return {
				list:[],
				list2:[],
				kalist:[],
				name:"",
				mobile:"",
				address2:"请选择省市区",
				address:"",
				yue:"",
				areaList:"",
				show:false,
				person:"",
				tishi9:false
			}
		},
		watch: {
			// num:function(newValue, oldValue) {
			//   console.log(newValue, oldValue)
			// }
		},
		computed: {
			// zongjia:function(){
			//   return this.num * 100
			// }
		},
		created() {
			axios.get("https://cdn.91haoka.cn/jsonwulianwangka3.json")
			  .then((response)=> {
				  this.areaList = response.data;
			  })
			this.huoquka()
			this.getyonghu()
			// this.getbalance()
			

		},
		methods: {
			go:function(url) {
				this.$router.push({
					path:url
				})
			},
			quxiao:function(e){
				if(e.length < this.list2.length){
					this.$dialog.confirm({
					  title: '放弃换卡确认',
					  message: '您仅有一次换卡机会，取消勾选表示您放弃该卡更换！',
					  overlay:true,
					  confirmButtonText:'确认放弃',
					  confirmButtonColor:'#f00',
					  cancelButtonText:'取消',
					  cancelButtonColor:'#4fc08d'
					})
					.then(() => {
						this.list2 = e
					})
					.catch(() => {
						this.list = this.list2
					});
				}else{
					this.list2 = e
				}
				
			},
			onAddressConfirm:function(values){
				console.log(values)
				this.address2 = values[0].name + values[1].name + values[2].name
				this.show = false
			},
			huanka:function(){
				if(!(/^1[3456789]\d{9}$/.test(this.mobile))){
					 vant.Toast('请填写正确的手机号！');
					 return false
				 }
				if(this.name =='' || this.mobile =='' || this.address =='' || this.address2 =='请选择省市区'){
					vant.Toast('填写收货信息！');
					return false
				}
				var that = this
				axios.post(this.url+`/mobile/api/reciveUserAddr?name=${this.name}&mobile=${this.mobile}&address=${this.address2}${this.address}`)
				.then((response)=>{
				    if(response.data.code == 200){
				  
						WeixinJSBridge.invoke(
						 'getBrandWCPayRequest', {
						      "appId":response.data.result.appId,
						      'timeStamp': response.data.result.timeStamp,
						      'nonceStr': response.data.result.nonceStr,
						      'package': response.data.result.package,
						      'signType': response.data.result.signType,
						      'paySign': response.data.result.paySign,
						 },
						 function(res){
							 
						       if(res.err_msg == "get_brand_wcpay_request:ok" ){
								    that.huoquka()
								    that.getyonghu()
								    setTimeout(()=>{
								    	that.$router.push('/')
								    },1000)
							   } 
						 }); 
				    }else{
						this.$toast(response.data.msg.info);
					}
				})
			},
			
			
			huoquka:function(){
				this.axios.get(this.url+`/mobile/api/getBandCardList`)
					.then(response => {
						if(response.data.success == true){
							let list = response.data.result
							for(let i in list){
								if(list[i].status == 2 && list[i].isSubmit ==0 ){
									this.list.push(list[i].iccid)
									this.kalist.push(list[i])
								}
							}
							console.log(this.kalist)
						}else{
							this.$toast(response.data.message);
						}
					})
			},
			getyonghu:function(){
				this.axios.get(this.url+`/mobile/api/getCountInfo`)
					.then(response => {
						if(response.data.success == true){
							this.person = response.data.result
						}else{
							this.$toast(response.data.message);
						}
					})
			},
			getbalance:function(){
				axios.get('/api/account/balance').then((response)=>{
				    if(response.data.msg.code == 0){
				        this.yue = parseFloat(response.data.data.balance).toFixed(2)
				    }else{
						vant.Toast(response.data.msg.info);
					}
				})
			},
			//获取url的code用
			getUrlParam:function(name) {   
			    var query = window.location.search.substring(1);
			    var vars = query.split("&");
			    for (var i=0;i<vars.length;i++) {
			            var pair = vars[i].split("=");
			            if(pair[0] == name){return pair[1];}
			    }
			    return(false);
			},
			fukuan:function(){
			    var that = this
			    axios.post(that.links + '/recharge/hua-pay', {money:this.value})
			        .then(response => {
			            if(response.data.msg.code == 0){
			               WeixinJSBridge.invoke(
			                'getBrandWCPayRequest', {
			                     "appId":"wx2d18b51e3875af9a",    
			                     'timeStamp': response.data.data.payInfo.timeStamp,
			                     'nonceStr': response.data.data.payInfo.nonceStr,
			                     'package': response.data.data.payInfo.package,
			                     'signType': 'MD5',
			                     'paySign': response.data.data.payInfo.paySign,
			                },
			                function(res){
			                      if(res.err_msg == "get_brand_wcpay_request:ok" ){} 
			                }); 
			            }else{
			                that.$message.error(response.data.msg.info);
			            }
			        })
			},

		},

	}
</script>

<style scoped lang="less">
	.all {
		background: #EDEDED;
		font-size: 0.28rem;
		min-height: 100vh;
		padding:0.5rem 0.3rem;
		.van-cell{ padding: 10px 0;}
		/deep/ .van-field__label{ color:#444444; text-align: right;}
		/deep/ .van-field__control{ padding-left: 0.2rem;}
		.jli {
			border-bottom: 1px #F1F3F5 solid;
			line-height: 0.5rem;
			padding-bottom: 0.1rem;
			margin-bottom: 0.2rem;
		}
		.tongzhi {
			width: 6.5rem;
			border-radius: 0.1rem;
			opacity: 0.9;
			font-size: 0.28rem;
		
			.ico {
				font-size: 0.28rem;
			}
		
			.tli {
				background: #FFB300;
				text-align: center;
				border-radius: 0.1rem;
				opacity: 0.6;
				width: 2.75rem;
				height: 1.4rem;
				padding: 0.2rem 0;
				flex-wrap: wrap;
				margin-bottom: 0.2rem;
		
				.czli {
					width: 100%;
				}
			}
		
			.tliact {
				opacity: 1;
			}
		
			.talt {
				font-size: 0.24rem;
				color: #93959B;
				padding: 0.2rem 0.4rem;
			}
		
			.tname {
				line-height: 0.95rem;
				border-bottom: 1px #EAEAEA solid;
				font-size: 0.32rem;
				color: #2D3038;
				text-align: center;
				font-weight: bold;
			}
		
			.tcon {
				padding: 0.2rem 0.4rem 0.4rem;
				line-height: 0.48rem;
				flex-wrap: wrap;
			}
		
			.tbon {
				border-top: 1px #EAEAEA solid;
			}
		
			.cli {
				flex: 1;
				text-align: center;
				font-size: 0.28rem;
				line-height: 0.75rem;
				margin: 0.1rem 0;
			}
		}
	}
</style>
